<<<<<<< HEAD
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Account_bank_model extends CI_Model {
	
	function __construct(){
        parent::__construct();
    }
    
    
	function arrays($key){
    	$data = array(
    		'var_account_bank'  => array(0=>"未填写",
						300=>"工商银行",301=>"中国银行",302=>"建设银行",303=>"农业银行",463=>"交通银行",
						465=>"广发银行",466=>"招商银行",467=>"平安银行",468=>"兴业银行",469=>"民生银行",
						470=>"华夏银行",471=>"浦发银行",472=>"中信银行",473=>"光大银行",493=>"深圳发展银行",
						494=>"桂林商业银行",495=>"湛江商行",496=>"鄞州银行",497=>"进出口银行",498=>"农业发展银行",
						499=>"国家开发银行",500=>"富滇银行",501=>"深圳农村商业银行",502=>"柳州市商业银行",503=>"吉林银行",
						504=>"上海农商行",505=>"西安商行",506=>"北京银行",507=>"上海银行",508=>"浙商银行",
						509=>"东亚银行",510=>"恒生银行",511=>"汇丰中国",512=>"渣打银行",513=>"花旗银行",
						514=>"星展银行",515=>"徽商银行",516=>"南京银行",517=>"恒丰银行",518=>"广州银行",
						519=>"厦门国际银行",520=>"荷兰银行",521=>"华侨银行",522=>"德意志银行",523=>"杭州银行",
						524=>"宁波银行",525=>"渤海银行",526=>"永亨银行中国",527=>"南商银行中国",528=>"友利银行中国",
						529=>"中信嘉华",530=>"巴黎银行中国",531=>"三菱东京日联银行",532=>"瑞穗银行",533=>"北京农商行",
						534=>"邮政储蓄银行",535=>"东莞银行",536=>"汉口银行",537=>"法国兴业银行",538=>"泉州商业银行",
						539=>"成都银行",540=>"厦门市商业银行",541=>"福建海峡银行",542=>"包商银行",543=>"大连银行",
						544=>"哈尔滨银行",545=>"大庆商行",
						),
				'var_account_cash_status' 	=> array("0"=>"申请", "1"=>"审核通过", "2"=>"审核拒绝", "3"=>"用户取消", "4"=>"到账"),
				'var_user_loan' 	=> array("0"=>"投资客", "1"=>"借款户"),
    	);
    	
    	if($key && isset($data[$key])){
    		return $data[$key];
    	}else{
    		return array();
    	}
    }
    
    function add($data = array()){
		if(isset($data['user_id'])){
			$this->db->insert('rsh_account_bank', $data);
			return $this->db->insert_id();
		}else{
			return false;
		}
	}
    
    function get_by_uid($user_id){
		
		$row = $this->mycache->get_array($key);
		if($row == false){
			$_sql  = "select * from rsh_account_bank where is_removal=0 and user_id = {$user_id} order by default_flag desc limit 0,2 ";
			$query = $this->db->query($_sql);;
			$row = $query->result_array ();
			$this->mycache->set_array($key,$row);
		}
		return $row;
	}
	
	
	
	function get_one($where = array(),$select='*'){
		$this->db->select($select);
		if($where){
			$this->db->where($where);
		}
		$this->db->limit(1);
		$query = $this->db->get('rsh_account_bank');
		//echo $query->row_array();exit;
		return $query->row_array();
	}
	
	function update($data = array(), $where = array()){
		if(isset($where['user_id'])){
			$this->db->where($where);
			$this->db->update('rsh_account_bank', $data);
			$res = $this->db->affected_rows();
			if($res > 0){
				$key = 'rsh_account_bank_'.$where['user_id'];
				$this->mycache->delete($key);
			}
			return $res;
		}else{
			return false;
		}
	}
	
	function delete($id,$data = array()){
		$this->db->where('id', $id);
		$this->db->update('rsh_account_bank',$data);
		$key = 'rsh_account_bank_' . $user_id;
		$this->mycache->delete($key);//@todo
		return $this->db->affected_rows();
	} 
    
=======
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Account_bank_model extends CI_Model {
    
	function __construct(){
        parent::__construct();
    }
    
    
	function arrays($key){
    	$data = array(
    		'var_account_bank'  => array(0=>"未填写",
						300=>"工商银行",301=>"中国银行",302=>"建设银行",303=>"农业银行",463=>"交通银行",
						465=>"广发银行",466=>"招商银行",467=>"平安银行",468=>"兴业银行",469=>"民生银行",
						470=>"华夏银行",471=>"浦发银行",472=>"中信银行",473=>"光大银行",493=>"深圳发展银行",
						494=>"桂林商业银行",495=>"湛江商行",496=>"鄞州银行",497=>"进出口银行",498=>"农业发展银行",
						499=>"国家开发银行",500=>"富滇银行",501=>"深圳农村商业银行",502=>"柳州市商业银行",503=>"吉林银行",
						504=>"上海农商行",505=>"西安商行",506=>"北京银行",507=>"上海银行",508=>"浙商银行",
						509=>"东亚银行",510=>"恒生银行",511=>"汇丰中国",512=>"渣打银行",513=>"花旗银行",
						514=>"星展银行",515=>"徽商银行",516=>"南京银行",517=>"恒丰银行",518=>"广州银行",
						519=>"厦门国际银行",520=>"荷兰银行",521=>"华侨银行",522=>"德意志银行",523=>"杭州银行",
						524=>"宁波银行",525=>"渤海银行",526=>"永亨银行中国",527=>"南商银行中国",528=>"友利银行中国",
						529=>"中信嘉华",530=>"巴黎银行中国",531=>"三菱东京日联银行",532=>"瑞穗银行",533=>"北京农商行",
						534=>"邮政储蓄银行",535=>"东莞银行",536=>"汉口银行",537=>"法国兴业银行",538=>"泉州商业银行",
						539=>"成都银行",540=>"厦门市商业银行",541=>"福建海峡银行",542=>"包商银行",543=>"大连银行",
						544=>"哈尔滨银行",545=>"大庆商行",
						),
				'var_account_cash_status' 	=> array("0"=>"申请", "1"=>"审核通过", "2"=>"审核拒绝", "3"=>"用户取消", "4"=>"到账"),
				'var_user_loan' 	=> array("0"=>"投资客", "1"=>"借款户"),
    	);
    	
    	if($key && isset($data[$key])){
    		return $data[$key];
    	}else{
    		return array();
    	}
    }
    
    function add($data = array()){
		if(isset($data['user_id'])){
			$this->db->insert('rsh_account_bank', $data);
			return $this->db->insert_id();
		}else{
			return false;
		}
	}
    
    function get_by_uid($user_id){
		
		$row = $this->mycache->get_array($key);
		if($row == false){
			$_sql  = "select * from rsh_account_bank where is_removal=0 and user_id = {$user_id} order by default_flag desc limit 0,2 ";
			$query = $this->db->query($_sql);;
			$row = $query->result_array ();
			$this->mycache->set_array($key,$row);
		}
		return $row;
	}
	
	
	
	function get_one($where = array(),$select='*'){
		$this->db->select($select);
		if($where){
			$this->db->where($where);
		}
		$this->db->limit(1);
		$query = $this->db->get('rsh_account_bank');
		//echo $query->row_array();exit;
		return $query->row_array();
	}
	
	function update($data = array(), $where = array()){
		if(isset($where['user_id'])){
			$this->db->where($where);
			$this->db->update('rsh_account_bank', $data);
			$res = $this->db->affected_rows();
			if($res > 0){
				$key = 'rsh_account_bank_'.$where['user_id'];
				$this->mycache->delete($key);
			}
			return $res;
		}else{
			return false;
		}
	}
	
	function delete($id,$data = array()){
		$this->db->where('id', $id);
		$this->db->update('rsh_account_bank',$data);
		$key = 'rsh_account_bank_' . $user_id;
		$this->mycache->delete($key);//@todo
		return $this->db->affected_rows();
	} 
    
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
}